


const url = require('url')
export default {
  setTime(time) {
    time = time * 60 * 60 * 1000
    time += new Date().getTime()
    time = new Date(time).toUTCString()
    return time
  },
  setCookie(key, value, time) {
    time = this.setTime(time)
    document.cookie = `${key}=${value};expires=${time};`
  },
  getCookie(val) {
    //使用node中的url核心模块
    let cookie = '?'
    cookie += document.cookie
    cookie = cookie.replace(/\;/g, '&')
    cookie = cookie.replace(/\s/g, '')
    cookie = url.parse(cookie, true).query
    return cookie
  }
}